using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

//UI Ctrl层: UI_Hurt
public class UI_Hurt : UGUICtrl
{
    public UI_Hurt_View selfView;
    private Tweener tw_hurt;

    public UI_Hurt()
    {
        OnCreate(ref selfView,"UGUI/ui_hurt","UI_Hurt");
    }

    /// <summary>
    /// 按钮添加事件
    /// </summary>
    protected override void ButtonAddClick()
    {
        //------------------按钮添加事件-----------------
        
    }

    /// <summary>
    /// 打开面板
    /// </summary>
    public override void OpenPanel(object data)
    {
        base.OpenPanel(data);
        selfView.img.color = new Color(selfView.img.color.r, selfView.img.color.g, selfView.img.color.b, 0);
    }
    
    public void Hurt()
    {
        Debug.Log("Hurt");
        if (tw_hurt != null)
        {
            tw_hurt.Restart();
        }
        else
        {
            tw_hurt = selfView.img.DOFade(1, 0.2f).SetLoops(2, LoopType.Yoyo).SetAutoKill(false);
        }
    }
}